package com.game.grid.GameStates;

import javax.microedition.khronos.opengles.GL10;

import com.game.grid.MainMenu;
import com.mcodesal.framework.GameEngine;
import com.mcodesal.framework.GameState;
import com.mcodesal.framework.ResourceProvider;
import com.mcodesal.framework.Sprite2D;
import com.mcodesal.framework.GameEngine.State;
import com.mcodesal.framework.ResourceProvider.Texture;
import android.view.MotionEvent;

public class Menu extends GameState {
	private Sprite2D mBackground;
	private MainMenu mMainMenu;

	//screen size when game is initialized.
	private int screenSizeX;
	private int screenSizeY;

	//boolean state flags.
	public boolean gamePaused = false;
	
	public Menu(GameEngine engine) {
        super(engine);
        mBackground = new Sprite2D(480, 800);
        mBackground.setFrameClip(0, 0, 320f/512f, 480f/512f );
        mBackground.setTexture(ResourceProvider.getInstance().getTexture(Texture.MENU_BACKGROUND));
        
        
        mMainMenu = new MainMenu();
	}

	@Override
    public void handleTouchEvent(MotionEvent event)
    {	
		engine.RequestStateChange(State.GAME);
    }
	
	@Override
	public void update(long gameTime) {

	}
    
    @Override
    public void render(GL10 gl) {
    	
		//Rendering Code
    	gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        
        gl.glPushMatrix();
        gl.glTranslatef(0, 0, 0);
		mBackground.draw(gl);
		gl.glPopMatrix();
		
		mMainMenu.draw(gl);
    	
    }
   
}
